from selenium import webdriver
from time import sleep

if __name__ == '__main__':
    brower = webdriver.PhantomJS(executable_path=r"E:\pytho-tool\webdriver\phantomjs-2.1.1-windows\bin\phantomjs.exe")
    brower.get("https://www.baidu.com/")
    sleep(2)
    brower.refresh()
    brower.maximize_window()

    search_text = brower.find_element_by_id("kw")
    search_text.send_keys("stanfurd is handsome boy")
    search_button = brower.find_element_by_id("su")
    search_button.click()
    sleep(3)

    js_height = "return document.body.clientHeight"
    height = brower.execute_script(js_height)
    print("execute js script is %s, the page height is %d " % (js_height, height))
    brower.save_screenshot("E:\pytho-tool\webphoto\stanford_by_phantom.png")


    # element = brower.find_element_by_link_text("新闻")
    # element.click()
    #brower.quit()
